#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require "#{LKP_SRC}/lib/statistics"
require "#{LKP_SRC}/lib/string_ext"
require "#{LKP_SRC}/lib/array_ext"
require "#{LKP_SRC}/lib/tests/stats"

stats = LKP::Stats.new

while (line = $stdin.gets)
  case line.uncolorize
  when /^(PASS|SKIP|FAIL|ignore_by_lkp:) ([a-zA-Z].*)/
    # ESC[32mPASSESC[0m vmexit_tscdeadline
    # PASS vmexit_tscdeadline

    test_result = $1.split(':')[0]
    test_name = $2.split(' ')[0]

    stats.add test_name, test_result
  end
end

stats.dump('ok' => 'pass', 'not_ok' => 'fail')
